<?php
/** .-------------------------------------------------------------------
 * |  Software: [HDCMS framework]
 * |      Site: www.hdcms.com
 * |-------------------------------------------------------------------
 * |    Author: 向军 <2300071698@qq.com>
 * |    WeChat: aihoudun
 * | Copyright (c) 2012-2019, www.houdunwang.com. All Rights Reserved.
 * '-------------------------------------------------------------------*/

namespace web\admin\controller;

class Brand extends Common{
    public function __construct(){
        parent::__construct();
        $this->db = new\system\model\Brand();
    }
    //动作
	public function index(){
       $data = $this->db->getAll();
		//此处书写代码...
        View::with('data',$data)->make();
	}
    public function add(){
        if(IS_POST){
            if($this->db->store()){
                message('添加成功',u('index'),'success');
            }
             message($this->db->getError(),'','error');
        }
        View::make();
    }
    public function edit(){
        if(IS_POST){
            if($this->db->edit()){
                message('编辑成功',u('index'),'success');
            }
            message($this->db->getError(),'','error');
        }
        $oldData = $this->db->where('bid',$_GET['bid'])->first();
        View::with('oldData',$oldData)->make();
    }
    public function del(){
        $bid = q('get.bid',0,intval);
        $this->db->where('bid',$bid)->delete();
        message('删除成功',U('index'),'success');
    }
}
